package nuc.edu.tlias.service.impl;

import nuc.edu.tlias.mapper.DeptMapper;
import nuc.edu.tlias.pojo.Dept;
import nuc.edu.tlias.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Time;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    DeptMapper deptMapper;
    @Override
    public List<Dept> findall() {
        List<Dept> list =  deptMapper.findall();
        return list;
    }

    @Override
    public void delectById(Integer id) {
        deptMapper.delectById(id);
    }

    @Override
    public void add(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());


        deptMapper.Insert(dept);
    }

    @Override
    public Dept getById(Integer id) {
        return deptMapper.getById(id);

    }

    @Override
    public void update(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.update(dept);
    }
}
